﻿package Game
{
	import Component.Result;
	import flash.display.MovieClip;
	import Game.Stats.TeamStat;
	import Game.Stats.PlayerStat;
	import flash.sampler.NewObjectSample;

	public class ScoreBoard extends MovieClip
	{

		protected var _result:Result;
		// vector avatar score

		private var teams:Vector.<TeamStat > ;
		private var players:Vector.<PlayerStat > ;

		public function ScoreBoard()
		{
			teams = new Vector.<TeamStat>();
			players = new Vector.<PlayerStat>();
		}

		public function set result(isVictorious:Boolean)
		{
			_result.result = isVictorious;
		}

		public function setTeamStats(id:uint,score:int)
		{
			teams[id].score = score;
		}

		public function setPlayerStats(id:uint,kills:uint,deaths:uint)
		{
			players[id].kills = kills;
			players[id].deaths = deaths;
		}

		protected function addTeam(team:TeamStat)
		{
			teams.push(team);
		}

		protected function addPlayer(player:PlayerStat)
		{
			player.avatar.colorize(players.length);
			players.push(player);
		}

		public function isWinner(winner:Boolean)
		{ 
			_result.result = winner;
			_result.visible = true;
		}


	}

}